package simpleftp.server;

import java.net.ServerSocket;

/**
 * Simple serveur TCP creant des thread pour gerer chaque connexion client.
 * 
 * @author lom
 */
public class FTPServerMain {

	/**
	 * Port d'ecoute.
	 */
	public static final int PORT = 7802;
	/**
	 * Socket server d'accueil.
	 */
	private static ServerSocket socketaccueil;

	public static void main(String argv[]) throws Exception 
	{
		// TODO MAKE IT MULTITHREAD (about 4 lines)
		try {
			socketaccueil = new ServerSocket(PORT);
			System.out.println("Server up and running.");
			FTPServer.setDebug(true);
			while (true) {
				FTPServer server = new FTPServer(socketaccueil.accept());
				//server.call();
				// TODO Modify for multithreading
				Thread t = new Thread(server);
				t.start();
			}
		} finally {
			if (socketaccueil != null) {
				socketaccueil.close();
			}
		}
	}
}
